﻿package mortal.game.view.guildNew.other
{
    import com.gengine.resource.*;
    import com.mui.controls.*;
    import mortal.component.gconst.*;
    import mortal.game.cache.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.guildNew.WareHourse.*;
    import mortal.game.view.guildNew.data.*;

    public class GuildNewHintPanel extends GSprite
    {
        public var wareHAllApplyNum:GuildNewWareHAppNum;
        public var applyToJoinNum:GuildNewWareHAppNum;
        private var _otherFriuts:GBitmap;
        private var _hasOtherFruits:Boolean = false;
        private var _skillNum:GuildNewWareHAppNum;

        public function GuildNewHintPanel()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.wareHAllApplyNum = UIFactory.getUICompoment(GuildNewWareHAppNum, 323, 23, this);
            this.wareHAllApplyNum.updateNum(0);
            this.applyToJoinNum = UIFactory.getUICompoment(GuildNewWareHAppNum, 121, 23, this);
            this.applyToJoinNum.updateNum(0);
            this._skillNum = UIFactory.getUICompoment(GuildNewWareHAppNum, 458, 23, this);
            this._skillNum.updateNum(0);
            LoaderHelp.addResCallBack(ResFileConst.guildNManor, this.onResLoad);
            return;
        }// end function

        private function onResLoad() : void
        {
            this._otherFriuts = UIFactory.gBitmap(ImagesConst.guidlRankFruite2, 253, 23, this);
            this._otherFriuts.visible = this._hasOtherFruits;
            GuildNewUtil.getManorInfo();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this.wareHAllApplyNum = null;
            this.applyToJoinNum = null;
            this._skillNum = null;
            this._otherFriuts = null;
            this._hasOtherFruits = false;
            super.disposeImpl(param1);
            return;
        }// end function

        public function updateApplyLabel() : void
        {
            if (GuildConst.hasPermissions(GuildConst.ManagerWareHouse))
            {
                this.wareHAllApplyNum.updateNum(Cache.instance.guild.selfGuildInfo.wareHouse.allApplyNum);
            }
            return;
        }// end function

        public function updateApplyToJoinLabel() : void
        {
            if (GuildConst.hasPermissions(GuildConst.ApproveIntoGuild))
            {
                this.applyToJoinNum.updateNum(Cache.instance.guild.selfGuildInfo.applyNum);
            }
            else
            {
                this.applyToJoinNum.updateNum(0);
            }
            return;
        }// end function

        public function updateSkillLabel() : void
        {
            if (GuildNewUtil.hasSkillToUpgrate())
            {
                this._skillNum.updateNum(GuildNewUtil.getSkillLeft());
            }
            else
            {
                this._skillNum.updateNum(0);
            }
            return;
        }// end function

        public function set hasOtherFruits(param1:Boolean) : void
        {
            this._hasOtherFruits = param1;
            if (this._otherFriuts)
            {
                this._otherFriuts.visible = this._hasOtherFruits;
            }
            return;
        }// end function

    }
}
